# -*- coding:utf-8 -*-
class Solution:
    # s 源字符串
    def replaceSpace(self, s):
        # write code here
        if not s:
            return ''

        l = len(s)
        c = 0
        for i in s:
            if i == ' ':
                c += 1
        a = [None] * (l + c * 2)
        nindex = len(a) - 1
        index = l - 1
        while nindex >= 0 and nindex >= index:
            if s[index] == ' ':
                a[nindex - 2:nindex + 1] = ['%', '2', '0']
                nindex -= 3
                index -= 1
            else:
                a[nindex] = s[index]
                index -= 1
                nindex -= 1
        return ''.join(a)

s = Solution()
print(s.replaceSpace('We Are Happy'))